package com.ruoyi.system.domain.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Date;
import java.util.List;

public class TCodeVo {
    @Data
    public static class Result {
        private Long codeId;

        @ApiModelProperty("ID")
        private Long id;
        @Excel(name = "变量名称")
        @ApiModelProperty("变量名称")
        private String name;
        @Excel(name = "变量CODE")
        @ApiModelProperty("变量CODE")
        private String code;
        @ApiModelProperty("标签列表")
        private List<TagResult> tagList;
        @Excel(name = "标签")
        private String tagName;
        @Excel(name = "创建人")
        @ApiModelProperty("创建人")
        private String createBy;
        @Excel(name = "创建时间", dateFormat = "yyyy-MM-dd HH:mm:ss")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        @ApiModelProperty("创建时间")
        private Date createTime;
        @ApiModelProperty("修改人")
        private String updateBy;
        @ApiModelProperty("修改日期")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        private Date updateTime;



        public String getTagName() {
            StringBuilder sb = new StringBuilder();
            for (TagResult tag : tagList) {
                sb.append(tag.getTagName()).append(",");
            }
            return sb.toString().substring(0, sb.length() - 1);
        }
    }

    @Data
    public static class TagResult {
        @ApiModelProperty("标签名称")
        private String tagName;
        @ApiModelProperty("标签ID")
        private Long tagId;
    }
}
